<template>
    <div class="task_form">

        <div class="com_box pd_box">
            <div class="pro_title">任务信息</div>
            <el-form-item label="所属项目">
                <div class="font_14 color_01">{{$route.query.name}}</div>
            </el-form-item>
            <el-form-item label="选择人员">
                <div class="member_box">
                    <div class="font_13 color_02">设置负责该任务的人员</div>
                    <div class="flexbox flexcenter member_item">
                        <div class="mem_title">媒介</div>
                        <el-form-item prop="media_worker" :rules="{required: true, message: '请选择媒介', trigger: ['blur', 'change']}" style="margin-left:20px">
                            <el-select v-model="addForm.media_worker" filterable placeholder="请选择媒介" style="width:220px" @change="setSessionStorage">
                                <el-option :label="item.nickname" :value="item.id" v-for="item in userList" :key="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div class="flexbox flexcenter member_item">
                        <div class="mem_title">内容</div>
                        <el-form-item prop="content_worker" :rules="{required: true, message: '请选择内容', trigger: ['blur', 'change']}" style="margin-left:20px">
                            <el-select v-model="addForm.content_worker" filterable placeholder="请选择内容" style="width:220px" @change="setSessionStorage">
                                <el-option :label="item.nickname" :value="item.id" v-for="item in userList" :key="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                    <div class="flexbox flexcenter member_item">
                        <div class="mem_title">项目经理</div>
                        <el-form-item prop="project_manager" :rules="{required: true, message: '请选择项目经理', trigger: ['blur', 'change']}" style="margin-left:20px">
                            <el-select v-model="addForm.project_manager" filterable placeholder="请选择项目经理" style="width:220px" @change="setSessionStorage">
                                <el-option :label="item.nickname" :value="item.id" v-for="item in userList" :key="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </div>
            </el-form-item>
        </div>
        <div class="com_box pd_box">
            <div class="pro_title">达人任务信息</div>
            <div class="steps_box">
                <div class="steps_item">
                    <div class="steps_num">1</div>
                    <div class="steps_line"></div>
                    <div class="steps_title flexbox flexcenter">选择达人</div>
                    <el-form-item label="" prop="aweme_name" label-width="0" :rules="{required: true, message: '请选择项达人', trigger: ['blur', 'change']}">
                        <el-select v-model="s_name" filterable remote reserve-keyword value-key="Uid" placeholder="请输入达人昵称" style="width:400px" class="aweme_el_select" popper-class="aweme_select" :remote-method="remoteMethod" :loading="s_loading" @change="selectAweme">
                            <template slot="prefix">
                                <div class="aweme_icon" style="line-height:39px">
                                    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                        <path d="M12.0208 11.0782L14.4044 13.4612C14.665 13.7217 14.665 14.144 14.4045 14.4045C14.144 14.665 13.7217 14.665 13.4612 14.4044L11.0782 12.0208C10.016 12.8723 8.69483 13.3354 7.3335 13.3335C4.0215 13.3335 1.3335 10.6455 1.3335 7.3335C1.3335 4.0215 4.0215 1.3335 7.3335 1.3335C10.6455 1.3335 13.3335 4.0215 13.3335 7.3335C13.3354 8.69483 12.8723 10.016 12.0208 11.0782ZM10.6835 10.5835C11.5296 9.71342 12.0021 8.54712 12.0002 7.3335C12.0002 4.75483 9.9115 2.66683 7.3335 2.66683C4.75483 2.66683 2.66683 4.75483 2.66683 7.3335C2.66683 9.9115 4.75483 12.0002 7.3335 12.0002C8.54712 12.0021 9.71342 11.5296 10.5835 10.6835L10.6835 10.5835Z" fill="#616C85" />
                                    </svg>
                                </div>
                            </template>
                            <el-option v-for="item in awemeOption" :key="item.Uid" :label="item.NickName" :value="item">
                                <div class="flexbox flexcenter">
                                    <img :src="item.Avatar" alt="" class="aweme_head">
                                    <div class="aweme_info">
                                        <div class="aweme_name">{{item.NickName}}</div>
                                        <div class="aweme_uid">UID:{{item.Uid}}</div>
                                    </div>
                                </div>
                            </el-option>
                        </el-select>
                        <div class="steps_data flexbox flexcenter pd_20" style="height:80px" v-if="addForm.aweme_name">
                            <img :src="addForm.aweme_headimg" alt="" class="aweme_head">
                            <div class="aweme_info">
                                <div class="aweme_name">{{addForm.aweme_name}}</div>
                                <div class="aweme_uid">达人 UID：{{addForm.aweme_id}}</div>
                            </div>
                        </div>
                        <div class="steps_data flexbox flexcenter flexjust" style="height:80px" v-else>
                            <img src="../../assets/img/null_icon.svg" width="56" alt="">
                        </div>
                    </el-form-item>
                </div>
                <div class="steps_item">
                    <div class="steps_num">2</div>
                    <div class="steps_line"></div>
                    <div class="steps_title flexbox flexcenter">选择任务订单</div>
                    <el-radio-group v-model="addForm.msg_type" size="small" style="margin-bottom:8px" @change="selectType">
                        <el-radio-button :label="1">选择订单录入</el-radio-button>
                        <el-radio-button :label="2">自定义填写</el-radio-button>
                    </el-radio-group>
                    <div v-if="addForm.msg_type==1" style="width:400px" v-loading="a_loading" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)">
                        <el-form-item label="" prop="aweme_name" label-width="0" style="margin-bottom:0px">
                            <el-select v-model="addForm.orderInfo" filterable value-key="order_id" placeholder="请选择订单" popper-class="aweme_select" style="width:100%" @change="selectOrder" @visible-change="getOrderData">
                                <div slot="empty" style="color:#c0c4cc;text-align:center;line-height:50px;font-size:14px">
                                    <template v-if="a_loading">正在加载</template>
                                    <template v-else>暂无数据</template>
                                </div>
                                <el-option :label="item.nick_name" :value="item" v-for="item in addForm.orderList" :key="item.order_id">
                                    <div class="order_select">
                                        <svg width="22" class="select_img" height="21" viewBox="0 0 22 21" fill="none" xmlns="http://www.w3.org/2000/svg">
                                            <path d="M18 0.152832H0L22 20.6528V4.15283C22 1.94369 20.2091 0.152832 18 0.152832Z" fill="#4475FF" />
                                            <circle cx="16" cy="6.15283" r="2" fill="white" />
                                        </svg>

                                        <div class="order_head flexbox flexcenter flexbetween">
                                            <div>{{item.order_name}}</div>
                                            <div>￥{{item.order_price}}</div>
                                        </div>
                                        <div class="flexbox flexcenter order_info">
                                            <img :src="item.avatar_uri" alt="" class="aweme_head">
                                            <div class="aweme_info">
                                                <div class="aweme_name">{{item.nick_name}}</div>
                                                <div class="aweme_uid">任务创建：{{item.create_time}}</div>
                                            </div>
                                            <div class="font_14 color_03" style="margin-left:auto" v-if="item.audit_status==1">未完成</div>
                                            <div class="font_14 color_01" style="margin-left:auto" v-else-if="item.audit_status==4">已完成</div>
                                        </div>
                                    </div>
                                </el-option>
                            </el-select>

                            <div class="steps_data" style="height:140px" v-if="addForm.orderInfo.order_id">
                                <div class="order_head flexbox flexcenter flexbetween">
                                    <div>{{addForm.orderInfo.order_name}}</div>
                                    <div>￥{{addForm.orderInfo.order_price}}</div>
                                </div>
                                <div class="flexbox flexcenter order_info">
                                    <img :src="addForm.orderInfo.avatar_uri" alt="" class="aweme_head">
                                    <div class="aweme_info">
                                        <div class="aweme_name">{{addForm.orderInfo.nick_name}}</div>
                                        <div class="aweme_uid">达人 UID：{{addForm.orderInfo.author_id}}</div>
                                        <div class="aweme_uid">任务创建：{{addForm.orderInfo.create_time}}</div>
                                    </div>
                                    <div class="font_14 color_03" style="margin-left:auto" v-if="addForm.orderInfo.audit_status==1">未完成</div>
                                    <div class="font_14 color_01" style="margin-left:auto" v-else-if="addForm.orderInfo.audit_status==4">已完成</div>
                                </div>
                            </div>
                            <div class="steps_data flexbox flexcenter flexjust" style="height:140px" v-else>
                                <img src="../../assets/img/null_icon.svg" width="56" alt="">
                            </div>
                        </el-form-item>
                    </div>
                    <div v-else>
                        <div class="font_14 color_02" style="margin-bottom:12px">收账主体名称</div>
                        <el-form-item label="" prop="getmoney_body" label-width="0" :rules="{required: true, message: '请输入收账主体名称', trigger: ['blur', 'change']}">
                            <el-input v-model="addForm.getmoney_body" placeholder="请输入收账主体名称" style="width:220px" @change="setSessionStorage">
                            </el-input>
                        </el-form-item>
                    </div>
                </div>
            </div>
            <div class="steps_divider"></div>
            <div class="pro_title">达人服务费</div>
            <el-form-item label="任务id" prop="task_id" v-if="addForm.msg_type==1">
                <el-input v-model="addForm.task_id" :disabled="addForm.msg_type==1" placeholder="请输入任务id" style="width:220px" @change="setSessionStorage">
                </el-input>
            </el-form-item>
            <el-form-item label="任务金额" prop="aweme_price" :rules="addRules.checkFloat">
                <el-input v-model="addForm.aweme_price" :disabled="addForm.msg_type==1" placeholder="请输入任务金额" style="width:220px" @change="setSessionStorage">
                    <i slot="prefix" style="font-style:normal;color:#17233D;margin-left:5px">￥</i>
                </el-input>
            </el-form-item>
            <el-form-item label="计算方式" prop="aweme_service_type">
                <el-radio-group v-model="addForm.aweme_service_type" @change="seletCountType">
                    <el-radio :label="1">比例计算</el-radio>
                    <el-radio :label="2">手动填写</el-radio>
                </el-radio-group>
            </el-form-item>
            <div  v-if="addForm.aweme_service_type==1" key="bili">
                <el-form-item label="返点比例" prop="aweme_ratio" :rules="addRules.checkFloat">
                    <el-input v-model="addForm.aweme_ratio" placeholder="请设置返点比例" style="width:220px" @change="setSessionStorage">
                        <i slot="suffix" style="font-style:normal;color:#17233D;margin-right:5px">%</i>
                    </el-input>
                </el-form-item>
                <el-form-item label="服务费金额">
                    <div class="font_14 color_01">￥{{this.getAwemeMoney}}</div>
                </el-form-item>
            </div>
            <div  v-else key="shoudong">
                <el-form-item label="返点比例">
                    <div class="font_14 color_01">无需填写</div>
                </el-form-item>
                <el-form-item label="服务费金额" prop="aweme_service" :rules="addRules.checkFloat">
                    <el-input v-model="addForm.aweme_service" placeholder="请输入任务金额" style="width:220px" @change="setSessionStorage">
                        <i slot="prefix" style="font-style:normal;color:#17233D;margin-left:5px">￥</i>
                    </el-input>
                </el-form-item>
            </div>
            <div class="steps_divider"></div>
            <div class="pro_title">日期信息</div>
            <el-form-item label="订单日期" prop="order_date">
                <el-date-picker style="width:220px" :disabled="addForm.msg_type==1" value-format="yyyy-MM-dd" placeholder="请选择收款日期" v-model="addForm.order_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
            <el-form-item label="上线日期" prop="online_date">
                <el-date-picker style="width:220px" :disabled="addForm.msg_type==1" value-format="yyyy-MM-dd" placeholder="请选择收款日期" v-model="addForm.online_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
            <el-form-item label="验收日期" prop="inspect_date">
                <el-date-picker style="width:220px" :disabled="addForm.msg_type==1" value-format="yyyy-MM-dd" placeholder="请选择收款日期" v-model="addForm.inspect_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
            <!-- <el-form-item label="达人搜索" prop="aweme_name">
                <el-select v-model="s_name" filterable remote reserve-keyword value-key="Uid" placeholder="请输入达人昵称" style="width:220px" class="aweme_el_select" popper-class="aweme_select" :remote-method="remoteMethod" :loading="s_loading" @change="selectAweme">
                    <template slot="prefix">
                        <div class="aweme_icon" style="line-height:39px">
                            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                                <path d="M12.0208 11.0782L14.4044 13.4612C14.665 13.7217 14.665 14.144 14.4045 14.4045C14.144 14.665 13.7217 14.665 13.4612 14.4044L11.0782 12.0208C10.016 12.8723 8.69483 13.3354 7.3335 13.3335C4.0215 13.3335 1.3335 10.6455 1.3335 7.3335C1.3335 4.0215 4.0215 1.3335 7.3335 1.3335C10.6455 1.3335 13.3335 4.0215 13.3335 7.3335C13.3354 8.69483 12.8723 10.016 12.0208 11.0782ZM10.6835 10.5835C11.5296 9.71342 12.0021 8.54712 12.0002 7.3335C12.0002 4.75483 9.9115 2.66683 7.3335 2.66683C4.75483 2.66683 2.66683 4.75483 2.66683 7.3335C2.66683 9.9115 4.75483 12.0002 7.3335 12.0002C8.54712 12.0021 9.71342 11.5296 10.5835 10.6835L10.6835 10.5835Z" fill="#616C85" />
                            </svg>
                        </div>
                    </template>
                    <el-option v-for="item in awemeOption" :key="item.Uid" :label="item.NickName" :value="item">
                        <div class="flexbox flexcenter">
                            <img :src="item.Avatar" alt="" class="aweme_head">
                            <div class="aweme_info">
                                <div class="aweme_name">{{item.NickName}}</div>
                                <div class="aweme_uid">UID:{{item.Uid}}</div>
                            </div>
                        </div>
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="达人昵称" prop="aweme_name" :rules="{required: true, message: '请先搜索达人', trigger: ['blur', 'change']}">
                <div class="font_14 color_01 aweme_text">{{addForm.aweme_name?addForm.aweme_name:"请先搜索达人"}}</div>
            </el-form-item>
            <el-form-item label="达人 UID" prop="aweme_id" :rules="{required: true, message: '请先搜索达人', trigger: ['blur', 'change']}">
                <div class="font_14 color_01 aweme_text">{{addForm.aweme_id?addForm.aweme_id:"请先搜索达人"}}</div>
            </el-form-item>
            <el-form-item label="任务 ID" prop="task_id" :rules="{required: true, message: '请输入任务 ID', trigger: ['blur', 'change']}">
                <el-input v-model="addForm.task_id" placeholder="请输入任务 ID" style="width:220px" @change="setSessionStorage"></el-input>
            </el-form-item> -->
        </div>
        <!-- <div class="com_box pd_box">
            <div class="pro_title">达人服务费</div>
            <el-form-item label="基数报价" prop="aweme_price" :rules="addRules.checkFloat">
                <el-input v-model="addForm.aweme_price" placeholder="请输入返点基数报价" style="width:220px" @change="setSessionStorage">
                    <i slot="prefix" style="font-style:normal;color:#17233D;margin-left:5px">￥</i>
                </el-input>
            </el-form-item>
            <el-form-item label="返点比例" prop="aweme_ratio" :rules="addRules.checkFloat">
                <el-input v-model="addForm.aweme_ratio" placeholder="请设置返点比例" style="width:220px" @change="setSessionStorage">
                    <i slot="suffix" style="font-style:normal;color:#17233D;margin-right:5px">%</i>
                </el-input>
            </el-form-item>
            <el-form-item label="服务费金额">
                <div class="font_14 color_01">￥{{this.getAwemeMoney}}</div>
            </el-form-item>
        </div> -->
        <!-- <div class="com_box pd_box">
            <div class="pro_title">日期</div>
            <el-form-item label="上线日期" prop="online_date">
                <el-date-picker style="width:220px" value-format="yyyy-MM-dd" placeholder="请选择上线日期" v-model="addForm.online_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
            <el-form-item label="验收日期" prop="inspect_date">
                <el-date-picker style="width:220px" value-format="yyyy-MM-dd" placeholder="请选择验收日期" v-model="addForm.inspect_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
            <el-form-item label="查款日期" prop="checkmoney_date">
                <el-date-picker style="width:220px" value-format="yyyy-MM-dd" placeholder="请选择查款日期" v-model="addForm.checkmoney_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
        </div> -->
        <div class="com_box pd_box">
            <div class="pro_title">收款信息</div>
            <el-form-item label="收款日期" prop="getmoney_date">
                <el-date-picker style="width:220px" value-format="yyyy-MM-dd" placeholder="请选择收款日期" v-model="addForm.getmoney_date" type="date" size="small" @change="setSessionStorage"></el-date-picker>
            </el-form-item>
            <el-form-item label="下单账户">
                <div class="flexbox flexcenter">
                    <el-form-item label="" prop="star_name">
                        <el-input :disabled="addForm.msg_type==1" v-model="addForm.star_name" placeholder="请输入账户名称" style="width:220px" @change="setSessionStorage"></el-input>
                    </el-form-item>
                    <el-form-item label="" prop="star_id" style="margin-left:10px">
                        <el-input :disabled="addForm.msg_type==1" v-model="addForm.star_id" placeholder="账户 ID" style="width:220px" @change="setSessionStorage"></el-input>
                    </el-form-item>
                </div>
            </el-form-item>
            <el-form-item label="付款人/主体" prop="pay_body" :rules="addForm.msg_type==1?{required: false}:{required: true, message: '请输入付款人/主体', trigger: ['blur', 'change']}">
                <el-input v-model="addForm.pay_body" placeholder="请输入付款人/主体信息" style="width:220px" @change="setSessionStorage">
                </el-input>
            </el-form-item>
            <el-form-item label="对公/对私" prop="account_type">
                <el-radio-group v-model="addForm.account_type" @change="setSessionStorage">
                    <el-radio :label="1">对公</el-radio>
                    <el-radio :label="2">对私</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="是否开票" prop="is_out_invoice">
                <el-radio-group v-model="addForm.is_out_invoice" @change="setSessionStorage">
                    <el-radio :label="0">否</el-radio>
                    <el-radio :label="1">是</el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="上传截图" prop="screenshot">
                <div class="ScreenShot">
                    <div class="pasteInputDiv" id="preview" @paste="handlePaste">
                        <div class="load_img" v-if="addForm.screenshot">
                            <div class="icon_list flexbox flexcenter flexjust">
                                <i class="el-icon-delete" @click="delImg"></i>
                                <i class="el-icon-zoom-in" @click="openBigImg(addForm.screenshot)" style="margin-left:10px"></i>
                            </div>
                            <img :src="addForm.screenshot" alt="" class="view_img">
                        </div>
                        <span v-else>将图片粘贴到此处</span>
                    </div>
                </div>
            </el-form-item>
        </div>
        <ViewBigImg ref="view_big" />
    </div>
</template>

<script>
import { clientInfo, clientTos, tosLink } from "../../assets/js/oss";
import ViewBigImg from "../common/ViewBigImg";
export default {
    components: {
        ViewBigImg,
    },
    props: ["addForm", "userList"],
    name: "",
    data() {
        return {
            s_loading: false,
            a_loading: false,
            s_name: "",
            awemeOption: [],
            addRules: {
                checkFloat: [
                    {
                        pattern:
                            /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
                        required: true,
                        message: "请输入正确数值",
                        trigger: ["blur", "change"],
                    },
                ],
            },
        };
    },
    created() {},
    computed: {
        getAwemeMoney() {
            return (this.addForm.aweme_price * (this.addForm.aweme_ratio / 100)).toFixed(2);
        },
    },

    methods: {
        remoteMethod(query) {
            if (query !== "") {
                this.getAwemeList(query);
            } else {
                this.awemeOption = [];
            }
        },

        toDate(time) {
            let date = new Date(time * 1000);
            let years = date.getFullYear();
            var month =
                date.getMonth() + 1 < 10
                    ? "0" + (date.getMonth() + 1)
                    : date.getMonth() + 1;
            var weekday =
                date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            return years + "-" + month + "-" + weekday;
        },

        // 计算方式
        seletCountType(){
            if(this.addForm.aweme_service_type == 1){
                this.addForm.aweme_service = ""
            }else{
                this.addForm.aweme_ratio = ""
            }
            this.setSessionStorage();
        },

        // 选择达人
        selectAweme(item) {
            this.s_name = "";
            this.addForm.aweme_headimg = item.Avatar;
            this.addForm.aweme_name = item.NickName;
            this.addForm.aweme_id = item.Uid;
            this.addForm.task_id = "";
            this.addForm.online_date = "";
            this.addForm.inspect_date = "";
            this.addForm.order_date = "";
            this.addForm.aweme_price = "";
            this.addForm.star_name = "";
            this.addForm.star_id = "";
            this.addForm.orderInfo = {};
            this.setSessionStorage();
        },

        // 选择订单 郎佳子
        selectOrder(item) {
            this.addForm.task_id = item.order_id;
            this.addForm.aweme_price = item.order_price;
            this.addForm.online_date = item.release_time;
            this.addForm.inspect_date = item.finish_time;
            this.addForm.order_date = item.create_time;
            this.addForm.star_name = item.star_name;
            this.addForm.star_id = item.star_id;
            this.setSessionStorage();
        },

        getOrderData(val) {
            if (val) {
                this.getOrder(this.addForm.aweme_name, this.addForm.project_id);
            }
        },

        // 切换输入类型
        selectType() {
            if (this.addForm.msg_type == 1) {
                let isNull = JSON.stringify(this.addForm.orderInfo);
                if (isNull == "{}") {
                    this.addForm.task_id = "";
                    this.addForm.online_date = "";
                    this.addForm.inspect_date = "";
                    this.addForm.order_date = "";
                    this.addForm.aweme_price = "";
                    this.addForm.star_name = "";
                    this.addForm.star_id = "";
                } else {
                    this.addForm.task_id = this.addForm.orderInfo.order_id;
                    this.addForm.aweme_price =
                        this.addForm.orderInfo.order_price;
                    this.addForm.online_date =
                        this.addForm.orderInfo.release_time;
                    this.addForm.inspect_date =
                        this.addForm.orderInfo.finish_time;
                    this.addForm.order_date =
                        this.addForm.orderInfo.create_time;
                    this.addForm.star_name = this.addForm.orderInfo.star_name;
                    this.addForm.star_id = this.addForm.orderInfo.star_id;
                }
            } else {
                this.addForm.task_id = "";
            }
            this.setSessionStorage();
        },
        // 获取达人
        async getAwemeList(report_name) {
            this.s_loading = true;
            const { data: res } = await this.$http.post(
                "fxdata/revenue/awemeList",
                {
                    name: report_name,
                }
            );
            let result = res;
            if (result.Code !== 200) {
                this.s_loading = false;
                this.$message.error(result.Msg);
                return;
            } else {
                this.s_loading = false;
                for (let i in result.Data.BloggerResult.List) {
                    result.Data.BloggerResult.List[i].Avatar =
                        result.Data.BloggerResult.List[i].Avatar.substring(
                            result.Data.BloggerResult.List[
                                i
                            ].Avatar.lastIndexOf("dyurl=") + 6
                        );
                }
                let list = result.Data.BloggerResult.List;
                this.awemeOption = list;
                // console.log(list);
                // this.awemeOption = list.filter((item) => {
                //     return (
                //         item.NickName.toLowerCase().indexOf(
                //             report_name.toLowerCase()
                //         ) > -1
                //     );
                // });
            }
        },

        //获取订单
        async getOrder(name, project_id) {
            this.addForm.orderList = [];
            this.a_loading = true;
            const { data: res } = await this.$http.post(
                "fxdata/revenue/taskList",
                {
                    name: name,
                    project_id: project_id,
                }
            );
            let result = res;
            if (result.code !== 200) {
                this.a_loading = false;
                this.$message.error(result.msg);
                return;
            } else {
                this.a_loading = false;
                for (let i in result.data) {
                    result.data[i].create_time = this.toDate(
                        result.data[i].create_time
                    );
                    result.data[i].release_time = this.toDate(
                        result.data[i].release_time
                    );
                    result.data[i].finish_time = this.toDate(
                        result.data[i].finish_time
                    );
                }
                this.addForm.orderList = result.data;
                // if(this.addForm.task_id){
                //     for(let i in result.data){
                //         if(this.addForm.task_id==result.data[i].order_id){
                //             this.addForm.orderInfo = result.data[i]
                //         }
                //     }
                // }
                this.setSessionStorage();
            }
        },

        // 监听粘贴操作
        handlePaste(event) {
            const items = (event.clipboardData || window.clipboardData).items;
            let file = null;

            if (!items || items.length === 0) {
                this.$message.error("当前浏览器不支持本地");
                return;
            }
            // 搜索剪切板items
            for (let i = 0; i < items.length; i++) {
                if (items[i].type.indexOf("image") !== -1) {
                    file = items[i].getAsFile();
                    break;
                }
            }
            if (!file) {
                this.$message.error("粘贴内容非图片");
                return;
            }
            // 此时file就是我们的剪切板中的图片对象
            // 如果需要预览，可以执行下面代码
            const reader = new FileReader();
            reader.readAsDataURL(file);
            this.uploadPlans(file);
        },

        //上传文件成功后回调
        async uploadPlans(files) {
            let file = files;
            var testmsg = file.name.substring(file.name.lastIndexOf("."));
            if (!file) {
                this.$message.error("请粘贴图片后上传");
                return;
            }
            let form = new FormData();
            form.append("file", file);
            form.append("type", file.type);
            const clienttos = clientTos;
            let date = Date.now();
            let rand = Math.floor(Math.random() * 900) + 100;
            let fileName = date + "" + rand + testmsg;
            let nowData = new Date();
            let year = nowData.getFullYear();
            let month =
                nowData.getMonth() + 1 < 10
                    ? "0" + (nowData.getMonth() + 1)
                    : nowData.getMonth() + 1;
            let day =
                nowData.getDate() < 10
                    ? "0" + nowData.getDate()
                    : nowData.getDate();
            let getData = year + "-" + month + "-" + day;
            let relativePath = "medium/" + getData + "/";
            const ret = await clienttos.putObject({
                key: relativePath + fileName,
                body: file,
            });
            if (ret.statusCode === 200) {
                let url = tosLink + relativePath + encodeURIComponent(fileName);
                this.addForm.screenshot = url;
                this.$message({
                    message: "上传成功！",
                    type: "success",
                });
                this.setSessionStorage();
            } else {
                this.$message.error("上传失败！");
            }
        },

        // 删除截图
        delImg() {
            this.addForm.screenshot = "";
            this.setSessionStorage();
        },

        // 缓存
        setSessionStorage() {
            this.$emit("setSessionStorage");
        },

        openBigImg(url) {
            this.$refs.view_big.getData(url);
        },
    },
};
</script>


<style scoped>
.pd_box {
    padding: 0 20px;
    overflow: hidden;
    margin-bottom: 12px;
}
.pro_title {
    font-weight: bold;
    font-size: 16px;
    height: 56px;
    line-height: 56px;
}

.member_box {
    border: 1px solid #ebebeb;
    border-radius: 2px;
    padding: 16px 20px;
}
.mem_title {
    width: 88px;
    font-size: 14px;
    color: #17233d;
}
.member_item {
    margin-top: 12px;
}
.aweme_head {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.aweme_info {
    margin-left: 12px;
}
.aweme_name {
    font-size: 14px;
    color: #17233d;
    line-height: 20px;
}
.aweme_uid {
    margin-top: 4px;
    font-size: 13px;
    line-height: 18px;
    color: #b4b7bd;
}
.aweme_text {
    line-height: 32px;
    height: 32px;
}
.pasteInputDiv {
    height: 100px;
    width: 200px;
    border: 1px dashed #ebebeb;
    cursor: pointer;
    text-align: center;
    line-height: 100px;
    font-size: 14px;
    color: #616c85;
    border-radius: 6px;
    overflow: hidden;
}
.load_img {
    width: 100%;
    height: 100%;
    position: relative;
}
.view_img {
    display: block;
    height: 100%;
    margin: 0 auto;
}
.icon_list {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 20px;
    display: none;
}
.load_img:hover .icon_list {
    display: block;
}
.steps_box {
}
.steps_item {
    position: relative;
    padding-left: 40px;
    overflow: hidden;
}
.steps_num {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    text-align: center;
    line-height: 18px;
    border: 1px solid #4475ff;
    font-size: 12px;
    color: #4475ff;
    position: absolute;
    left: 0;
    top: 0;
    background: #fff;
    z-index: 2;
}
.steps_line {
    position: absolute;
    left: 9px;
    top: 0;
    bottom: 0;
    border-left: 1px solid #4475ff;
}
.steps_title {
    font-size: 14px;
    color: #17233d;
    margin-bottom: 12px;
}
.steps_data {
    width: 400px;
    box-sizing: border-box;
    border-radius: 4px;
    border: 1px solid #ebebeb;
    margin-top: 8px;
}
.steps_divider {
    border-top: 1px solid #ebebeb;
    margin-top: 20px;
}
.order_head {
    margin: 0 20px;
    height: 44px;
    border-bottom: 1px solid #ebebeb;
}
.order_info {
    padding-left: 20px;
    padding-right: 20px;
    margin-top: 12px;
}
.order_select {
    height: 120px;
    box-sizing: border-box;
    border-radius: 6px;
    border: 1px solid #ebebeb;
    position: relative;
    color: #17233d;
    font-weight: normal;
    overflow: hidden;
}
.select_img {
    position: absolute;
    right: 0;
    top: 0;
    display: none;
}
</style>
<style>
.task_form .el-form-item__label {
    color: #616c85 !important;
}
.task_form .el-form-item__label {
    line-height: 16px !important;
    margin-top: 7px;
}
.aweme_select .el-select-dropdown__item {
    height: auto;
    line-height: unset;
    padding-top: 5px;
    padding-bottom: 5px;
}
.aweme_el_select .el-input__prefix {
    left: unset;
    right: 10px;
}
.aweme_el_select .el-input--small .el-input__inner {
    padding-left: 15px;
}
.aweme_select .el-select-dropdown__item.hover,
.aweme_select .el-select-dropdown__item:hover {
    background-color: unset;
}
.aweme_select .el-select-dropdown__item.selected .order_select {
    border: 1px solid #4475ff;
}
.aweme_select .el-select-dropdown__item.selected .order_select .select_img {
    display: block;
}
</style>

